<!--style-->
<style>
    #win-email-personal .unit .l {
        width: 70px;
        text-align: right;
    }

    #win-email-personal .unit .r {
        width: 180px;
    }

    #win-email-personal .unit input {
        width: 160px;
    }
</style>
<!--style-->

<!--html-->
<div class="form" data-focus="true">
      <p class="alert alert-warning">
        安全邮箱用于找回密码。请谨慎设置。
      </p>
      
    <!--<div class="unit">
        <div class="l">
            <p class="subtitle">现有邮箱</p>
        </div>
        <div class="r">
            <input id="ipt-email-old-personal" class="email disabled" data-name="现有邮箱" data-length="6,64" type="email">
        </div>
        <span class="clearfix"></span>
    </div>-->

    <div class="unit">
        <div class="l">
            <p class="subtitle">现有密码</p>
        </div>
        <div class="r">
            <input id="ipt-pwd-old-personal" class="req" data-name="现有密码" data-length="6,20" type="password"
                   data-placeholder="mimiko">
        </div>
        <span class="clearfix"></span>
    </div>

    <div class="unit">
        <div class="l">
            <p class="subtitle">安全邮箱</p>
        </div>
        <div class="r">
            <input id="ipt-email-personal" class="email" data-name="安全邮箱" data-length="6,64" type="email">
        </div>
        <span class="clearfix"></span>
    </div>

    <div class="unit-tool">
        <div class="l">
            <button class="btn success do">
                <i class="icon white icon-ok-circle"></i>提交修改
            </button>
        </div>
        <div class="r">
        </div>
        <span class="clearfix"></span>
    </div>

</div>
<!--html-->

<!--script-->
<script>
    system.tv = function () {
        //set handle
        var win = $('#win-email-personal');
        var form = win.find('div.form').eq(0);
        //action
        form.setup({
            //
            finish: function () {
                $('#ipt-pwd-old-personal')
                        .val('');
                $('#ipt-email-personal')
                        .val($('#unit-email').data().email);
            },
            callback: function () {
                $.post('api/user/emailSubmit', {
                    origPwd: form.data().req,
                    newEmail: form.data().email
                })
                        .done(function (data) {
                            //
                            if (!!data.success) {
                                //info
                                $.info('success::邮箱修改成功。');
                                //close
                                $('#curtain').click();
                            } else {
                                var text = 'error::' + data.result;
                                $.info(text);
                                win.info(text);
                            }
                            ;
                        })
                        .fail(function () {
                            var text = 'error::同服务器通信失败。请于稍后重试。';
                            $.info(text);
                            win.info(text);
                        });
            }
        });
    }();
</script>
<!--script-->